Skip to content

Fix GP7 score metadata export for Guitar Pro multitrack view#2774

Open
chenkigba wants to merge 1 commit into
CoderLine:developfrom
chenkigba:fix/gp7-score-multitrack-metadata
Open

Fix GP7 score metadata export for Guitar Pro multitrack view#2774
chenkigba wants to merge 1 commit into
CoderLine:developfrom
chenkigba:fix/gp7-score-multitrack-metadata

Conversation

@chenkigba

Copy link
Copy Markdown

Summary

This PR fixes a small GPIF metadata serialization issue in the GP7/GP8 exporter that can make Guitar Pro 8 unstable when switching an exported .gp file to multitrack view.

The change is intentionally minimal:

  • write ScoreSystemsDefaultLayout as text instead of CDATA
  • write ScoreSystemsLayout as text instead of CDATA
  • write MultiVoice as 0 instead of the invalid-looking 1> value
  • add an exporter regression test that checks the generated Content/score.gpif

Root cause

Before this change, alphaTab exports the top-level GPIF score metadata like this:

<ScoreSystemsDefaultLayout><![CDATA[3]]></ScoreSystemsDefaultLayout>
<ScoreSystemsLayout><![CDATA[1]]></ScoreSystemsLayout>
<MultiVoice>1></MultiVoice>

Files with this shape can open in Guitar Pro 8, but switching to multitrack view can trigger abnormal memory growth. Native Guitar Pro files use plain text for these layout fields, and a stable MultiVoice value:

<ScoreSystemsDefaultLayout>3</ScoreSystemsDefaultLayout>
<ScoreSystemsLayout>1</ScoreSystemsLayout>
<MultiVoice>0</MultiVoice>

Reproduction

  1. Generate a two-track GP7 file from AlphaTex using the exporter before this patch.
  2. Inspect Content/score.gpif in the exported .gp zip.
  3. Confirm the score metadata contains:
<ScoreSystemsDefaultLayout><![CDATA[3]]></ScoreSystemsDefaultLayout>
<ScoreSystemsLayout><![CDATA[1]]></ScoreSystemsLayout>
<MultiVoice>1></MultiVoice>
  1. Open the generated .gp in Guitar Pro 8.
  2. Switch to multitrack view.

Observed with Guitar Pro 8.1.5 on macOS: the file opens, but switching to multitrack view can increase RSS from about 450 MB to about 2.48 GB before the process is killed by the probe threshold.

Verification

Unit tests

npm ci
npm run generate-typescript --workspace=packages/alphatab
npm run test --workspace=packages/alphatab -- test/exporter/Gp7Exporter.test.ts
npm run typecheck --workspace=packages/alphatab
npm run lint --workspace=packages/alphatab

Results from this branch:

  • Gp7Exporter.test.ts: 19 passed
  • typecheck: passed
  • lint: exited successfully; it reports existing warnings unrelated to this PR

Exported GPIF check

The new test alphatex-to-gp7-score-metadata exports a two-track AlphaTex score and asserts that the exported GPIF contains:

<ScoreSystemsDefaultLayout>3</ScoreSystemsDefaultLayout>
<MultiVoice>0</MultiVoice>

and no longer contains:

<ScoreSystemsDefaultLayout><![CDATA[
<ScoreSystemsLayout><![CDATA[
<MultiVoice>1></MultiVoice>

Guitar Pro 8 UI validation

I also generated a .gp file from this patched branch and opened it with Guitar Pro 8.1.5 on macOS. A small probe script opened the file, clicked the 多音轨 / multitrack menu item via System Events, and sampled process RSS.

Patched branch result:

{
  "ok": true,
  "stage": "done",
  "reason": "opened and switched multitrack within thresholds",
  "appVersion": "8.1.5-31",
  "openMaxRssMb": 414.3,
  "switchMaxRssMb": 421.3,
  "switchGrowthMb": 7.0,
  "clickResult": "clicked 多音轨"
}

The same problematic file shape before the metadata fix failed the probe after switching to multitrack view:

{
  "ok": false,
  "stage": "switch-monitor",
  "reason": "rss exceeded limit: 2482.2 MB >= 1536.0 MB",
  "appVersion": "8.1.5-31",
  "openMaxRssMb": 450.6,
  "switchMaxRssMb": 2482.2,
  "switchGrowthMb": 2031.6,
  "clickResult": "clicked 多音轨"
}

@chenkigba

Copy link
Copy Markdown
Author

For the reviewer:

First, thank you for this project. I use it in my own website, it's really really helpful!

Then, forgive me, I posted this PR by gpt5.5 xhigh.

But, only 3 line of code changed, I think it's reviewable.

And, I manually tested this fix in my case, it passed.

Picture 1: rendered by alphatab in my website
image

Picture 2: export from alphatab to .gp then import in guitar pro with multi-track view.
image

: )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants